package array

import (
	"fmt"
	"sort"
	"strconv"
)

func findRelativeRanks(score []int) []string {

	rankMap := map[int]string{
		0: "Gold Medal",
		1: "Silver Medal",
		2: "Bronze Medal",
	}

	n := len(score)
	type pair struct {
		score int
		index int
	}

	arr := []pair{}
	for i, v := range score {
		arr = append(arr, pair{v, i})
	}

	sort.Slice(arr, func(i, j int) bool {
		return arr[i].score > arr[j].score
	})

	fmt.Println(arr)

	res := make([]string, n)

	for i, v := range arr {
		if i < 3 {
			res[v.index] = rankMap[i]
		} else {
			res[v.index] = strconv.Itoa(i + 1)
		}
	}
	return res

}
